package cn.bellychang.leetcode.question704;

/**
 * @author ChangLiang
 * @date 2021/3/8
 */
public class Solution2 {

    public int search(int[] nums, int target) {
        return search(nums, target, 0, nums.length-1);
    }

    private int search(int[] nums, int target, int begin, int end){
        if(begin>end){
            return -1;
        }
        int mid = ((end - begin)>>2) + begin;
        if(nums[mid]==target){
            return mid;
        }else if(nums[mid]>target){
            return search(nums, target, begin, mid-1);
        }else{
            return search(nums, target, mid+1, end);
        }
    }
}
